<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <!-- 引入 echarts.js -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.2.1/echarts.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/lib/jquery.min.js"></script> 
</head>
<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        num =[];
        category = [];

        $.ajax({
            url: '{:U('admin/count/countajax')}',
            type: 'post',
            async: false,
            dataType: 'json',
            success:function  (data) {
                for (var row in data) {
                    num.push(data[row].cn);
                    category.push(data[row].days);
                };
            }
        })

        


        // alert(num);
        // alert(category);
        

        // num = [2000, 1200, 300, 200, 900, 300];
        // category = ['一周','7-01','7-2','7-3','7-4','7-5'];

        option = {
            title: {
                text: 'XX社区一周提问量统计（单位:个）',
                subtext: 'From ExcelHome',
                sublink: 'http://e.weibo.com/1341556070/AjQH99che',
            },
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'line'        // 默认为直线，可选为：'line' | 'shadow'
                },
                formatter: function (params) {
                    var tar = params[1];
                    return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type : 'category',
                splitLine: {show:false},
                data : category
            },
            yAxis: {
                type : 'value'
            },
            series: [
                {
                    name: '提问题',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'inside'
                        }
                    },
                    data:num
                }
            ]
        };


        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>
</html>